<?php

namespace App\Sdks\Feishu\Traits;

trait Token
{
    /**
     * @var
     * token
     */
    protected $tenantAccessToken;

    /**
     * @param $tenantAccessToken
     * @return bool
     * 设置 token
     */
    public function setTenantAccessToken($tenantAccessToken){
        $this->tenantAccessToken = $tenantAccessToken;
        return true;
    }

    /**
     * @return mixed
     * 获取 token
     */
    public function getTenantAccessToken(){
        $url = $this->getApiUrl('get_tenant_access_token');

        $param = [
            'app_id' => $this->appId,
            'app_secret' => $this->appSecret,
        ];

        $ret = $this->publicRequest($url, $param, 'POST');

        return $ret;
    }
}
